<template>
	<view class="mv">
		<video class="video" :src="mvid" autoplay="true" danmu-btn="true" controls></video>
	</view>
</template>

<script>
	import {
		getMvVideo,
		getRelevant
	} from '@/network/search2.js'
	export default {
		data() {
			return {
				mvid: ""
			}
		},
		methods: {
			geturl() {
				getMvVideo(this.mvid).then(res => {
					console.log(res);
					if (res.code !== 200) return uni.$showMsg()
					console.log(res.data)
					this.mvid = res.data.url
				})
			},
			getRelevantUrl(){
				getRelevant(this.mvid).then(res => {
					console.log(res);
				})
			}

			// async geturl() {
			// 	const {
			// 		data: res
			// 	} = getMvVideo(this.mvid)
			// 	if (res.code !== 200) return uni.$showMsg()
			// 	console.log(res.data)
			// 	this.mvid = res.data.url
			// }
		},
		onReady(options) {
			this.getRelevantUrl()
			this.geturl()
			this.videoContext = uni.createVideoContext('myVideo')
		},
		// updated() {
		// 	this.geturl()
		// },
		onLoad(options) {
			this.mvid = options.id
		}
	}
</script>

<style lang="scss" scoped>
.video{
	width: 100%;
}
</style>	